﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace XEvents.Library
{
    internal struct dm_xe_object_column
    {
        internal string name;
        internal int column_id;
        internal string object_name;
        internal Guid object_package_guid;
        internal string type_name;
        internal Guid type_package_guid;
        internal string column_type;
        internal string column_value;
        internal int capabilities;
        internal string capabilities_desc;
        internal string description;

        internal dm_xe_object_column(SqlDataReader dr)
        {

            name = (dr["name"] == DBNull.Value ? string.Empty : dr["name"]).ToString();
            Int32.TryParse((dr["column_id"] == DBNull.Value ? "-1" : dr["column_id"]).ToString(), out column_id);
            object_name = (dr["object_name"] == DBNull.Value ? string.Empty : dr["object_name"]).ToString();
            Utilities.IsGuid((dr["object_package_guid"] == DBNull.Value ? string.Empty : dr["object_package_guid"]).ToString(), out object_package_guid);
            type_name = (dr["type_name"] == DBNull.Value ? string.Empty : dr["type_name"]).ToString();
            Utilities.IsGuid((dr["type_package_guid"] == DBNull.Value ? string.Empty : dr["type_package_guid"]).ToString(), out type_package_guid);
            column_type = (dr["column_type"] == DBNull.Value ? string.Empty : dr["column_type"]).ToString();
            column_value = (dr["column_value"] == DBNull.Value ? string.Empty : dr["column_value"]).ToString();
            Int32.TryParse(dr["capabilities"].ToString(), out capabilities);
            capabilities_desc = dr["capabilities_desc"].ToString();
            description = dr["description"].ToString();
        }
    }
}
